<?php

class AboutController extends \BaseController {
    protected $layout = 'layouts.admin_panel';
    
    public function __construct(About $about, Media $media) {
        parent::__construct();
        $this->about = $about;
        $this->media = $media;
    }
    
    /**
     * Display About for edit
     * @author Thuan Truong
     * @return responses
     */
    public function index() {
        $abouts = $this->about->getAllAbouts();
        $view = View::make('about.index')->with(array(
            'abouts' => $abouts,
        ));
        if (Request::ajax()) {
            return $this->ajaxResponse($view, Lang::get('nav.page.abouts.index'));
        } else {
            $this->layout->content = $view;
        }
    }
    
    /**
     * update abouts
     * @author Thuan Truong
     */
    public function update() {
        $input = array_map('trim', Input::all()); 
        $this->about->updateAbouts($input);
        
        Session::flash('f_notice', 'Cài đặt đã được lưu lại thành công');
        return Response::json(array(
            'status' => 1,
            'redirect' => route('admin.about.index'),
        ));
    }
    
}